import 'package:environmental_les_app/common/style/colours.dart';
import 'package:flutter_clx_base/flutter_clx_base.dart';

class BasicInfoCard extends StatelessWidget {
  final String title;
  final Widget child;
  final bool? isExpanded;
  final String cardKey;
  final void Function()? onTap;
  const BasicInfoCard(
      {super.key,
      required this.title,
      required this.child,
      this.isExpanded = true,
      required this.cardKey,
      this.onTap});

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.symmetric(horizontal: 15, vertical: 5),
      padding: const EdgeInsets.all(12),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          GestureDetector(
            onTap: onTap,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Row(
                  children: [
                    Container(
                      width: 3,
                      height: 15,
                      color: Colours.appMain,
                    ),
                    hGap8,
                    Text(
                      title,
                      style: const TextStyle(
                          fontSize: 16,
                          fontWeight: FontWeight.w500,
                          color: Colours.text254),
                    ),
                  ],
                ),
                Row(
                  children: [
                    Text(
                      isExpanded! ? "收起" : "展开",
                      style:
                          const TextStyle(fontSize: 14, color: Colours.appMain),
                    ),
                    Icon(
                      isExpanded!
                          ? Icons.arrow_drop_up_outlined
                          : Icons.arrow_drop_down_outlined,
                      color: Colours.appMain,
                    )
                  ],
                )
              ],
            ),
          ),
          if (isExpanded!) vGap15,
          if (isExpanded!) child,
        ],
      ),
    );
  }
}
